var a = getApp();

Page({
    data: {
        videoArr: [],
        shareVideoArr: [],
        article: [],
        can_recovery: !1,
        showShare: !1,
        options: [ {
            name: "视频",
            icon: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FtaskPackage%2Fshipin.png",
            router: "VideoList"
        }, {
            name: "文章",
            icon: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FtaskPackage%2Fwenzhang.png",
            router: "notice"
        } ],
        acticeMonth: "",
        acticeDay: "",
        page: 1,
        info: {},
        time: ""
    },
    onLoad: function(a) {
        wx.setNavigationBarColor({
            frontColor: "#ffffff",
            backgroundColor: "#FF8924",
            animation: {
                duration: 400,
                timingFunc: "easeIn"
            }
        }), wx.setNavigationBarTitle({
            title: "任务包"
        }), a.id && this.setData({
            id: a.id
        }), this.setData({
            acticeMonth: new Date().getFullYear() + "-" + (new Date().getMonth() + 1)
        }), this.getData(), this.getDailyData();
    },
    toMy: function() {
        wx.navigateTo({
            url: "/packageI/taskPackage/taskPackageMy/taskPackageMy"
        });
    },
    shareHandle: function(a) {
        "VideoList" == a.currentTarget.dataset.item.router ? wx.navigateTo({
            url: "/packageC/video_goods/VideoList/VideoList?taskID=".concat(this.data.id, "&taskDay=").concat(this.data.acticeDay)
        }) : wx.navigateTo({
            url: "/packageA/member/notice/notice?taskID=".concat(this.data.id, "&taskDay=").concat(this.data.acticeDay)
        });
    },
    childGet: function(a) {
        this.getDailyData(a.detail.date);
    },
    showShareCanle: function() {
        this.setData({
            showShare: !1
        });
    },
    makeTask: function() {
        this.setData({
            showShare: !0
        });
    },
    payTask: function() {
        var t = this;
        a._getNetWork({
            url: a.getNetAddresss("plugin.task-package.frontend.recovery.create"),
            data: {
                record_id: this.data.id,
                day: this.data.acticeDay
            },
            success: function(a) {
                var e = a.data;
                1 == e.result && t.payTaskCreat(e.data.recovery_order_id);
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    payTaskCreat: function(t) {
        a._getNetWork({
            url: a.getNetAddresss("plugin.task-package.frontend.create.index"),
            data: {
                recovery_order_id: t
            },
            success: function(a) {
                var t = a.data;
                1 == t.result && wx.navigateTo({
                    url: "/packageD/buy/orderPay/orderPay?order_id=".concat(t.data.order_ids)
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getData: function() {
        var t = this;
        a._getNetWork({
            url: a.getNetAddresss("plugin.task-package.frontend.record.info"),
            data: {
                id: this.data.id,
                month: this.data.acticeMonth
            },
            success: function(a) {
                var e = a.data;
                1 == e.result && (t.setData({
                    info: e.data
                }), t.timeCountDown(t.data.info.active_end));
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    timeCountDown: function(a) {
        var t = this.formatIosDate(a), e = new Date(t += " 23:59:59").getTime() - Number(new Date().getTime().toFixed(0));
        this.setData({
            time: e
        });
    },
    formatIosDate: function(a) {
        return a.replace(/\-/g, "/");
    },
    onChange: function(a) {
        this.setData({
            timeData: a.detail
        });
    },
    getDailyData: function(t) {
        var e = this;
        this.data.acticeDay = t || this.data.acticeMonth + "-" + new Date().getDate(), this.setData({
            acticeDay: this.data.acticeDay
        }), a._getNetWork({
            url: a.getNetAddresss("plugin.task-package.frontend.daily.info"),
            data: {
                record_id: this.data.id,
                day: this.data.acticeDay
            },
            success: function(a) {
                var t = a.data;
                if (1 == t.result) {
                    var i = t.data, o = i.can_recovery, n = i.video, c = i.share, s = i.article, r = i.usable_name;
                    e.setData({
                        usable_name: r || "可用爱心值",
                        can_recovery: o || !1,
                        videoArr: n || [],
                        shareVideoArr: c || [],
                        article: s || []
                    });
                }
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    toRecord: function() {
        wx.navigateTo({
            url: "/packageI/taskPackage/record/record?type=1&id=" + this.data.info.id
        });
    },
    onReady: function() {},
    onShow: function() {
        this.setData({
            showShare: !1
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});